package com.bawei.mine.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import androidx.transition.Visibility
import com.bawei.image.ImgOptions
import com.bawei.image.LoadImageUtil
import com.bawei.mine.databinding.ItemOrderMessBinding
import com.bawei.mine.entity.Data
import com.bumptech.glide.Glide
import com.tencent.mmkv.MMKV


class GoodsOrdersAdapter(private val list :MutableList<Data>) :RecyclerView.Adapter<GoodsOrdersAdapter.OrderViewHolder>()  {

inner class OrderViewHolder(val   item_mess :ItemOrderMessBinding) :RecyclerView.ViewHolder(item_mess.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OrderViewHolder {

        return OrderViewHolder(ItemOrderMessBinding.inflate(LayoutInflater.from(parent.context) , parent, false))
    }

    override fun getItemCount(): Int  =list.size

    @SuppressLint("SuspiciousIndentation")
    override fun onBindViewHolder(holder: OrderViewHolder, position: Int) {

        val itemData = list[position]
        holder.item_mess.tvPrice.text=itemData.goods_default_price.toString()
        holder.item_mess.tvProductName.text =itemData.goods_code
        holder.item_mess.tvProductSpec.text=itemData.goods_desc
            Glide.with(holder.item_mess.root.context).load(itemData.goods_default_icon).into(holder.item_mess.ivProduct)
        holder.item_mess.tvOrderNumber.text=itemData.goods_attribute
        holder.item_mess.tvOrderStatus.text=MMKV.defaultMMKV().getString("orderState","全部订单")




    }



}